import java.util.Scanner;

public class Solution {
    public void moveZeroes(int[] nums){
        for (int cur = 0,dest = -1; cur < nums.length; cur++) {
            if(nums[cur] != 0){
                dest++;
                int temp = nums[cur];
                nums[cur] = nums[dest];
                nums[dest] = temp;
            }
        }
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while(in.hasNextInt()){
            int size = in.nextInt();
            int[] arr = new int[size];
            for (int i = 0; i < size; i++) {
                arr[i] = in.nextInt();
            }
            Solution solution = new Solution();
            solution.moveZeroes(arr);
            for (int i = 0; i < size; i++) {
                System.out.print(arr[i]+" ");
            }
        }
    }
}
